package com.pureut.production.controller;

import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.production.domain.dto.CutOrdersDocumentDetailDto;
import com.pureut.production.domain.dto.CutOrdersDocumentDto;
import com.pureut.production.domain.vo.CutOrdersDocumentVo;
import com.pureut.production.domain.vo.SubvolumeAndroidVo;
import com.pureut.production.service.CutOrdersDocumentDetailService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/***
 * 分切制令单明细控制层
 * Author:C
 * Date:2023/02/16 16:21
 * @DESC
 */
@RestController
@RequestMapping("/cut-orders-document-detail")
public class CutOrdersDocumentDetailController extends BaseController {

    @Resource
    CutOrdersDocumentDetailService cutOrdersDocumentDetailService;

    /**
     * 分切制令单明细列表
     */
    @GetMapping("/list")
    public TableDataInfo selectOperationList(String documentNum) {
        startPage();
        // 查询分切制令单明细列表
        List<CutOrdersDocumentDetailDto> list = cutOrdersDocumentDetailService.getList(documentNum);
        return getDataTable(list);
    }

    /**
     * 根据产品号码获取明细
     */
    @GetMapping("/view")
    public AjaxResult getView(String productNumber) {
        return AjaxResult.success(cutOrdersDocumentDetailService.getView(productNumber));
    }

    /**
     * 手持pda 分卷
     */
    @PostMapping("/subvolumeAndroid")
    public AjaxResult subvolumeAndroid(@RequestBody SubvolumeAndroidVo subvolumeAndroidVo) throws Exception {
        return AjaxResult.success(cutOrdersDocumentDetailService.subvolumeAndroid(subvolumeAndroidVo));
    }

    /**
     * 分切制令单明细列表（feign调用）
     */
    @GetMapping("/detailList")
    public AjaxResult detailList(String documentNum) {
        // 查询分切制令单明细列表
        return AjaxResult.success(cutOrdersDocumentDetailService.getList(documentNum));
    }

    /**
     * 查询母卷是否分切
     */
    @GetMapping("/getCutOrdersDocumentInfo")
    public AjaxResult getCutOrdersDocumentInfo(String masterVolumeNumber) {
        return AjaxResult.success(cutOrdersDocumentDetailService.getCutOrdersDocumentInfo(masterVolumeNumber));
    }
}
